<template>
	<view class="content mainpadding2">
		<u-tabs :list="tabList" :scrollable="false" @click="tabchange" lineWidth="60rpx"
			lineColor="rgba(255, 184, 0, 1)" :activeStyle="{
		  color: '#000000',
		  fontWeight: 800,
		  transform: 'scale(1.05)'}" :inactiveStyle="{
		  color: '#666666',
		    transform: 'scale(1)'
		}"></u-tabs>
		<view class="mainpadding_top ffffff border2" v-for="item in list.data" :key="item.id" @click="jumpdetail('/pages_message/noticeDetail?id=',item.id)">
			<view class="flexbetween">
				<view class="stateBox text_e radius color2">{{item.title}}</view>
				<view class="color_six text_five margin_top2">{{item.createtime_text}}</view>
			</view>
			<view class="margin_top color_ling text_a padding_bottom border_bottom">
				{{item.des}}
			</view>
			<view class="flexright margin_top2">
				<view class="lanlable">看詳情</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				tabsid: 1,
				tabList: [{
					name: "公告",
					id: 1,
				}, {
					name: "活動",
					id: 2,
				}],
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			tabchange(e) {
				if(e.id==1){
					uni.setNavigationBarTitle({
						title:"公告"
					})
				}else{
					uni.setNavigationBarTitle({
						title:"活動"
					})
				}
				this.tabsid = e.id
				this.init()
				this.list.data = []
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/index/ptnewsIndex', 'GET', {
					page: page || 1,
					limit: _this.limit,
					type: this.tabsid
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style>
	.stateBox{
		padding: 5rpx 15rpx;
	}
.color2 {
		color: #fff;
		background: #9064ff;
	}
</style>
